using System;

namespace NetFrameworkExtensions.Utils
{
  public interface IKeyedReadonlyReference
  {
    object this[object key] { get; }
  }
  public interface IKeyedReadonlyReference<in TKey, out TValue> : IKeyedReadonlyReference
  {
    TValue this[TKey key] { get; }
  }

  [Serializable]
  public abstract class KeyedReadonlyReferenceBase<TKey, TValue> : IKeyedReadonlyReference<TKey, TValue>
  {
    object IKeyedReadonlyReference.this[object key]
    {
      get
      {
        return this[(TKey) key];
      }
    }

    public abstract TValue this[TKey key] { get; }
  }
}